import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication

from ui.chakan import Ui_MainWindow
from PyQt5 import QtWidgets
import pymysql


class cha(QtWidgets.QMainWindow,Ui_MainWindow):
    def __init__(self,data):
        super(cha,self).__init__()
        self.setupUi(self)
        self.data = data

        self.Initsold()



    def Initsold(self):
        conn = pymysql.connect(
            host='localhost',  # 主机名
            port=3306,  # 端口号
            user='root',  # 用户名
            password='xjy123456',  # 密码
            autocommit=True  # 自动提交更改
        )
        cursor = conn.cursor()
        # 选择数据库
        conn.select_db('face_recognition')

        sql = "select name,age,gender,phone,case1 from face where pinyin='{}';".format(self.data)
        # print(sql)
        cursor.execute(sql)
        result = cursor.fetchall()
        cursor.close()  # 关闭游标
        conn.close()  # 关闭连接
        self.lineEdit_name.setText(result[0][0])
        self.lineEdit_age.setText(result[0][1])
        self.lineEdit_gender.setText(result[0][2])
        self.lineEdit_phone.setText(result[0][3])
        self.lineEdit_bl.setText(result[0][4])




if __name__ == '__main__':
    QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    # 适应高DPI设备
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    # 解决图片在不同分辨率显示模糊问题
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = cha()
    MainWindow.show()
    sys.exit(app.exec_())
